

















//吐司提示
//	var Base={
//		getStyle:function(obj){
//			if(obj.currentStyle){
//				return obj.currentStyle
//			}else{
//				return getComputedStyle(obj,false)	
//			}	
//		},
//	}
//	function showToast(message){
//		var toast=document.getElementById("toast");
//		toast.innerHTML=message
//		clearInterval(timer);
//		var timer=setInterval(function(){
//			if(parseFloat(Base.getStyle(toast).opacity)>=0.8){
//				clearInterval(timer);
//				setTimeout(hideToast,500)
//			}else{
//				toast.style.opacity=parseFloat(Base.getStyle(toast).opacity)+0.01
//			}
//			
//		},10)
//	}
//	
//	function hideToast(){
//		var toast=document.getElementById("toast");
//		clearInterval(timer);
//		var timer=setInterval(function(){
//			if(parseFloat(Base.getStyle(toast).opacity)<=0){
//				clearInterval(timer);
//					
//			}else{
//				toast.style.opacity=parseFloat(Base.getStyle(toast).opacity)-0.01	
//			}
//				
//		},10)	
//	}

function showToast(message){
	$("#toast").html(message)
	$("#toast").fadeIn(1000,function(){
		setTimeout(function(){
			$("#toast").fadeOut(1000);
		},500)
	});
}
//以上吐司提示
//获取参数
	function GetQueryString(name){
		/*定义正则，用于获取相应参数*/
	     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
		 /*字符串截取，获取匹配参数值*/
	     var r = window.location.search.substr(1).match(reg);
		 /*但会参数值*/
	     if(r!=null)return  decodeURI(r[2]); return null;
	};
	//一下获取地理信息定位
	var default_position="深圳";//默认用户所在城市
	var position_flag=true;
	function getMyposition(){
		var geolocation = new qq.maps.Geolocation("N6LBZ-GQJKU-LRKVR-2GJTI-DPLNV-B7FA4", "kouan");
		geolocation.getIpLocation(showPosition, showErr)
		function showPosition(position) {
			default_position=position.city;
			
			 window.sessionStorage.setItem("realposition",default_position);
			position_flag=false;
		};
		function showErr(data) {
//			alert(data)
			alert("定位失败");
			window.sessionStorage.setItem("realposition",default_position);
			position_flag=false
		};
	}
	
	
	//localstorage过期处理
		
	
	
	function getLocation(){//一下源生h5定位+百度地图接口
		console.log(navigator.geolocation)
	    if (navigator.geolocation){ 
	        navigator.geolocation.getCurrentPosition(showPosition,showError); 
	    }else{
	        alert("浏览器不支持地理定位。");
	        position_flag=false;
	    } 
	};
	function showError(error){ 
	    switch(error.code) { 
	        case error.PERMISSION_DENIED: 
//	            alert("定位失败,用户拒绝请求地理定位");
				position_flag=false;
				window.sessionStorage.setItem("realposition",default_position)
	            break; 
	        case error.POSITION_UNAVAILABLE: 
	            alert("定位失败,位置信息是不可用");
	            position_flag=false;
	            window.sessionStorage.setItem("realposition",default_position)
	            break; 
	        case error.TIMEOUT: 
	            alert("定位失败,请求获取用户位置超时");
	            position_flag=false;
	            window.sessionStorage.setItem("realposition",default_position)
	            break; 
	        case error.UNKNOWN_ERROR: 
	            alert("定位失败,定位系统失效");
	            position_flag=false;
	            window.sessionStorage.setItem("realposition",default_position)
	            break; 
	    } 
	};
	function showPosition(position){ 
	    var lat = position.coords.latitude; //纬度 
	    var lag = position.coords.longitude; //经度 
	    var point = new BMap.Point(lag,lat);
//				var point = new BMap.Point(114.520487,37.992269);
	    var geoc = new BMap.Geocoder();
		geoc.getLocation(point, function(rs){
			var addComp = rs.addressComponents;
			default_position=addComp.city;
			window.sessionStorage.setItem("realposition",default_position);
//			if($("#now_position")){
//				$("#now_position").html(default_position)
//			}
			position_flag=false;
		});  	
	}
	
	
	
	
	
	
	
	//以上获取地理信息定位
	//配置接口变量
	  var url_enter="http://app1.sztravel.com.cn";
	//	var url_enter="https://www.ai-peer.com"
	//调取接口配置
		if(!window.sessionStorage.getItem("svr_config")){
			$.ajax({
				type:"get",
				url:url_enter+"/api/query_svr_config",
				async:true,
				success:function(data){
					console.log(data)
					window.sessionStorage.setItem("svr_config",JSON.stringify(data));
				}
			});
		}
	//调取接口配置
	
//确定是 ios还是android
	var u = navigator.userAgent;
	var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //是否是android 布尔值
	var ios_Andriod;
	isAndroid == true ? ios_Andriod = 'Andriod' : ios_Andriod = 'Ios';
	//$.get("http://119.23.70.141/api/banner",function(data){
	//    console.log(data);
	//})

	//用localStorage处理token
	//					localStorage.token = "";
	//					var abc = localStorage.token = "";

	//获取屏幕宽高
	var clientWidth = (document.documentElement.clientWidth);
	var clientHeight = (document.documentElement.clientHeight);
	var wh = clientWidth + "*" + clientHeight;
//如果有session storage 那么将其接受 
	if(sessionStorage.user_id){
		var user_id=sessionStorage.user_id;
		console.log(user_id);
	}
	if(sessionStorage.token){
		var token=sessionStorage.token;
		console.log(token);
	};
//配置统一头部
		var headers={
						"User-Token":token,
						"Os":ios_Andriod,
						"Screen": wh,
						"Device-Id":"",
						"Content-Type": "application/x-www-form-urlencoded"
				};
//	
var my_volg;
function live1(){//存在旅游专家
	var svr_config=JSON.parse(window.sessionStorage.getItem("svr_config"));
	console.log(svr_config)
	my_volg=JSON.parse(sessionStorage.getItem("my_volg"));
	console.log(my_volg)
	if(svr_config.data.fixed_mavin===0){//正常显示
		
		$(".service-list .s-center").attr("dep_id",my_volg.dep_id)
		$(".service-list .s-center img").attr("src",my_volg.head_img);
		$(".service-list .s-center .s-right span").eq(0).html("我的旅游专家："+my_volg.names);
		$(".service-list .s-center .s-right span").eq(1).html("营业部："+my_volg.dep_name);
		$(".service-list .s-center .s-right span").eq(2).html("电话："+my_volg.phone_num);
		$("#service").click(function(){
			$(".service-list").toggle()
		});
		$(".service-list .s-center .btn1").click(function(){
			window.location.href="stewardnow.html";
		});	
		$("#heart_to_steward").click(function(){
			
			window.location.href="stewardnow.html"
		});
		$(".btn2").click(function(){
			window.location.href="mqqwpa://im/chat?chat_type=wpa&uin="+my_volg.qq+"&version=1&src_type=web&web_src=oicqzone.com";  
		})
		$(".btn3").click(function(){
			window.location.href="tel:"+my_volg.phone_num+""
		})
	}else if(svr_config.data.fixed_mavin===1){//不可切换专家显示两个
		if(my_volg.qq){//存在QQ//显示两个 居中
			$(".btn1").remove();
			$(".btn2").css("margin-right","-0.5rem");
			$(".btn3").css("margin-left","1.5rem");
			$(".service-list .s-center").attr("dep_id",my_volg.dep_id);
			$(".service-list .s-center img").attr("src",my_volg.head_img);
			$(".service-list .s-center .s-right span").eq(0).html("我的旅游专家："+my_volg.names);
			$(".service-list .s-center .s-right span").eq(1).html("营业部："+my_volg.dep_name);
			$(".service-list .s-center .s-right span").eq(2).html("电话："+my_volg.phone_num);
			$("#service").click(function(){
				$(".service-list").toggle();
			});
			$(".btn2").click(function(){
				window.location.href="mqqwpa://im/chat?chat_type=wpa&uin="+my_volg.qq+"&version=1&src_type=web&web_src=oicqzone.com";  
			})
			
		}else{//不存在QQ//显示一个居中
			$(".btn1").remove();
			$(".btn2").remove();
			$(".btn3").css({"width":"63%","padding":"0"})
			$(".service-list .s-center").attr("dep_id",my_volg.dep_id);
			$(".service-list .s-center img").attr("src",my_volg.head_img);
			$(".service-list .s-center .s-right span").eq(0).html("我的旅游专家："+my_volg.names);
			$(".service-list .s-center .s-right span").eq(1).html("营业部："+my_volg.dep_name);
			$(".service-list .s-center .s-right span").eq(2).html("电话："+my_volg.phone_num);
			$("#service").click(function(){
				$(".service-list").toggle();
			});
		};
		$(".btn3").click(function(){	
			window.location.href="tel:"+my_volg.phone_num+""
		})
		$("#heart_to_steward").click(function(){
			showToast("专家已固定，暂时无法切换");
		})
	}
	
}
	my_volg=null;
	function live2(){//不存在旅游专家
		//显示客服
		$("#service").click(function(){
			$(".service-list1").toggle()
		});
		$(".btn-right").click(function(){
			$(".s-center").slideUp(200,function(){
				$(".service-list1").hide();
				$(".s-center").show()
			});
		});
		$(".btn-left").click(function(){
			window.location.href="stewardnow.html";
		});
		$("#heart_to_steward").click(function(){
			window.location.href="stewardnow.html"
		})
	}






